package org.example.utils.common;

import com.baidu.aip.contentcensor.AipContentCensor;
import com.baidu.aip.contentcensor.EImgType;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.List;

public class BaiduUtil {

    public static String checkImageUrl(List<String> urls, AipContentCensor client) throws JSONException {
        String res = null;
        for (String url : urls) {
            JSONObject conclusion = client.imageCensorUserDefined(url, EImgType.URL, null);
            res = conclusion.getString("conclusion");
            if(res.equals("不合规")||res.equals("疑似"))
                return res;
        }
       return res;
    }

    /*public static String checkVideoUrl(List<String> urls, AipContentCensor client) throws JSONException {
//        String res = null;
//        for (String url : urls) {
//            JSONObject conclusion = client.videoCensorUserDefined(url, EImgType.URL, null);
//            res = conclusion.getString("conclusion");
//            if(res.equals("不合规")||res.equals("疑似"))
//                return res;
//        }
//        return res;
    }*/

    public static String checkTextContent(String content, AipContentCensor client) throws JSONException {
        JSONObject res = client.textCensorUserDefined(content);
        System.out.println(res.toString(2));
        return res.getString("conclusion");
    }

}
